// 基于axios的封装，网络请求的函数
import axios from 'axios'
import store from '@/store'

// axios.create()创建一个带配置的自定义axios函数
const myAxios = axios.create({
    baseURL: 'http://127.0.0.1:3000',
    timeout: 5000,
    headers: {
        Authorization: localStorage.token
    }
})


axios.interceptors.request.use(function (config) {
    // config.headers['token'] = window.sessionStorage.getItem('token')
    if (localStorage.token) {
        config.headers.Authorization = localStorage.token
    }
    console.log(localStorage.token);
    return config
}, function (error) {
    return Promise.reject(error)
})
// 导出自定义函数
export default myAxios




